<template>
  <div>
    <nav-bar>
      <div slot="left" class="back" @click="backClick">
        <img src="~assets/img/common/back.svg" alt="">
        </div>
      <div class="contral-item" slot="center">
        <div
          v-for="(item, index) in titles"
          :key="index"
          class="item"
          :class="{ active: index == currentIndex }"
          @click="itemClick(index)"
        >
          {{ item }}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar.vue";
export default {
  name: "ChildDetail",
  components: {
    NavBar,
  },
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentIndex: 0,
    };
  },
  methods:{
    itemClick(index){
      this.currentIndex = index,
      this.$emit('itemClick',index)
    },
    backClick(){
      this.$router.back()
    }
  }
};
</script>

<style scoped>
.contral-item {
  display: flex;
}
.item {
  flex: 1;
  font-size: 13px;
}
.active{
  color: hotpink;
}
.back{
  padding-top: 7px;
  font-size: 7px;
}
</style>